package com.example.leo.mycharmingstudent.a0911;

import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.example.leo.mycharmingstudent.R;
import com.example.leo.mycharmingstudent.a0905.ToastUtil;

public class LifeActivity extends AppCompatActivity {

    private static final String TAG = "A";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_life);
        findViewById(R.id.btn_jump_to_b_activity_life).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(LifeActivity.this, LifeActivity2.class));
            }
        });
        findViewById(R.id.btn_pop_dialog_activity_life).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //弹出对话框
                AlertDialog.Builder builder = new AlertDialog.Builder(LifeActivity.this);
                builder.setTitle("中午饭提示")
                        .setMessage("中午有锅包肉，吃不")
                        .setPositiveButton("吃", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                ToastUtil.showToast(LifeActivity.this,"恭喜选对了");
                            }
                        })
                        .setNeutralButton("想想", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                ToastUtil.showToast(LifeActivity.this,"已经都被吃完了");
                            }
                        })
                        .setNegativeButton("不吃", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                ToastUtil.showToast(LifeActivity.this,"不要钱");
                            }
                        })
                        .show();
            }
        });
        Log.e(TAG, "onCreate: ");
    }

    @Override
    protected void onStart() {
        super.onStart();
        Log.e(TAG, "onStart: ");
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.e(TAG, "onResume: ");
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.e(TAG, "onPause: ");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.e(TAG, "onStop: ");
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        Log.e(TAG, "onRestart: ");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.e(TAG, "onDestroy: ");
    }


    //Activity被意外回收，咋整？////////////////////////////////////////////////////////////////////////

    /**
     * Activity被意外回收，回调此方法
     *
     * @param outState 保存数据的Bundle
     */
    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
    }

    /**
     * Activity被意外回收，onSaveInstanceState保存了数据，回调此方法
     *
     * @param savedInstanceState onSaveInstanceState方法保存的数据Bundle
     */
    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
    }
    //////////////////////////////////////////////////////////////////////////
}
